//
//  TZNavigationController.m
//  wangYiCaiPiao
//
//  Created by mac on 16/1/4.
//  Copyright © 2016年 tz. All rights reserved.
//

#import "TZNavigationController.h"

@interface TZNavigationController ()

@end

@implementation TZNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    //设置导航条的背景图片
    [self.navigationBar setBackgroundImage:[UIImage imageNamed:@"NavBar64"] forBarMetrics:UIBarMetricsDefault];
    //设置字体的颜色为白色
    [self.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
    //设置默认渲染染色为白色
    [self.navigationBar setTintColor:[UIColor whiteColor]];
    
}

//重写导航控制器的push方法，隐藏bottom bar
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    if (self.childViewControllers.count != 0) {
        viewController.hidesBottomBarWhenPushed = YES;
        UIButton *btn = [[UIButton alloc]init];
        [btn setImage:[UIImage imageNamed:@"NavBack"] forState:UIControlStateNormal];
        [btn sizeToFit];
        [btn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
        UIBarButtonItem *backItem = [[UIBarButtonItem alloc]initWithCustomView:btn];
        viewController.navigationItem.leftBarButtonItem = backItem;
    }
    [super pushViewController:viewController animated:animated];
}

- (void)back{
    [self popViewControllerAnimated:YES];
}

//修改状态栏的样式
- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}
@end
